import axios from 'axios';
import qs from 'qs';

axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.withCredentials = true
axios.interceptors.request.use((config) => {
    return config;
})
axios.interceptors.response.use((response) => {
    if(response.data){
        return response.data
    }else{
        return response;
    }
}, (error) => {
    return Promise.reject(error);
})

export function post(url, data) {
    return axios.post(url, qs.stringify(data));
}

export function get(url, params) {
    return axios.get(url, {params});
}